import { request, baseStatAPI } from '@/service/request'
import { formatDate } from '@/utils/date'

export interface StatDataProps {
  eventKey: string
  eventDate: string
  eventData: {
    pv: number
  }
  [key: string]: any
}

export async function getPV(startTime?: Date, endTime?: Date) {
  const params = {
    category: 'h5',
    action: 'pv',
    startDate: formatDate(startTime),
    endDate: formatDate(endTime)
  }
  const rawData = await request<StatDataProps[]>(baseStatAPI + '/event', 'get', params)
  return rawData.data
}
